package com.yjd.job.order;

import com.alibaba.edas.schedulerX.ProcessResult;
import com.alibaba.edas.schedulerX.ScxSimpleJobContext;
import com.alibaba.edas.schedulerX.ScxSimpleJobProcessor;
import com.yjd.comm.order.service.IOrderService;
import com.yjd.comm.util.*;
import org.apache.log4j.Logger;

import javax.annotation.Resource;

/**
 * 订单失效检查更新（超过24小时未只支付订单）
 * Created by yjd-wap on 2017/11/21.
 */
public class OrderOverdueCheckJob implements ScxSimpleJobProcessor {
    Logger logger = Logger.getLogger(OrderOverdueCheckJob.class);

    @Resource
    private IOrderService orderService;

    @Override
    public ProcessResult process(ScxSimpleJobContext scxSimpleJobContext) {
        Long currentTime = FrameUtil.getTime();
        try {
            logger.info("订单有效期检查更新，日期：" + currentTime + "开始");
            orderService.updateInvalidOrderStatus(FrameUtil.newHashMap("invalidTime", currentTime - 86400));
            logger.info("订单有效期检查更新，日期：" + currentTime + "结束");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return new ProcessResult(true);
    }
}
